package com.dx.architectureddd.common.dp.rule;

import java.util.List;

/**
 * 业务执行逻辑
 *
 * @author xin.deng
 * @date 2023/09/24
 */
public class DefaultRule<T> implements Rule<T> {
    private final List<RuleBuilder<T>.RulePair> list;

    public DefaultRule(final List<RuleBuilder<T>.RulePair> list) {
        this.list = list;
    }

    @Override
    public void process(T t) {
        list.forEach(p -> {
            if (p.getCondition().test(t)) {
                p.getAction().accept(t);
            }
        });
    }
}
